Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: switch from jest to vitest #10412

Merged
merged 3 commits into from
Jan 29, 2024
Merged

test: switch from jest to vitest #10412

merged 3 commits into from
Jan 29, 2024

Conversation

JammingBen
Copy link
Contributor

@JammingBen JammingBen commented Jan 26, 2024

Description

Removes jest in favour of vitest for our unit test suite. The API remains nearly unchanged (expect for that jest now became vi).

Unfortunately we lose our nice snapshot formatter. We have to see if there is some äquivalent for vitest.

Possibly/hopefully fixes #10380.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests
  • Documentation
  • Maintenance (e.g. dependency updates or tooling)

Followup Tasks

  • eslint rules
  • vscode integration
  • happy dom
  • sharing?
  • single config file for vite and vitest
  • remove HttpClient cancel function which makes little sense from our pov

@JammingBen JammingBen self-assigned this Jan 26, 2024
Copy link

update-docs bot commented Jan 26, 2024

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@JammingBen JammingBen force-pushed the vitest branch 2 times, most recently from c20c8f2 to 29c144d Compare January 26, 2024 16:18
@JammingBen JammingBen marked this pull request as ready for review January 29, 2024 11:19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure ... doesn't this code take care we're logging vue warnings to the console? Do we have that in vitest ootb or should we keep/port this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I don't know to be honest. Definitely something we should check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file gone?

Copy link
Contributor Author

@JammingBen JammingBen Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you correctly assumed that's because the corresponding test is being skipped and never actually ran once with vitest.

// region: { enabled: false }
// }
// })
// ).toHaveNoViolations()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this skipped?
Is this the reason the snapshot is gone? Although this test was skipped before already ...
Can't we fix it or add at least a comment what fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a comment already, this test has always been flaky and I don't know why and how to fix it 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I thought we don't use axe anymore... if I remember correctly this was just a quick test / use case for automated accessibility tests. Since we didn't follow up I'd say completely get rid of it for now (here and in OcTable).

packages/web-runtime/tests/unit/components/Avatar.spec.ts Outdated Show resolved Hide resolved
expect(catchFn).toHaveBeenCalledWith(expect.any(mockAxios.Cancel))
done()
})
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added removal of HttpClient to the followup tasks... was easier for now to just remove the test than to port it. The function is unused anyhow...

packages/web-pkg/tests/unit/helpers/datetime.spec.ts Outdated Show resolved Hide resolved
expect(clientService.owncloudSdk.shares.getShares).toHaveBeenCalledTimes(4)

// FIXME: pqueue makes issues?!
// expect(clientService.owncloudSdk.shares.getShares).toHaveBeenCalledTimes(4)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uaaaaaaarghs - what do we make out of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't find a solution 😅 That's the only place where this causes issues...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be potentially better to use fake timers than sleeping 600ms?

Not that it matters thaaaat much in this single test but in theory...

Copy link
Contributor Author

@JammingBen JammingBen Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it, but it didn't work for some reason. The docs are mentioning only setTimeout and setInterval... maybe we can't use it for lodash's debounce.

Copy link

@JammingBen JammingBen mentioned this pull request Jan 29, 2024
7 tasks
Copy link
Member

@kulmann kulmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

@kulmann kulmann merged commit e2bfffd into master Jan 29, 2024
3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the vitest branch January 29, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nightly failures on multiple unit tests
3 participants